import request from "@/utils/request";
//密码规则
export function getUserPwdRule() {
  return request({
    url: "/system/findpwd/getUserPwdRule",
    method: "get",
  });
}
// 登录方法
export function login(userCode, password, verifyCode, verifyCodeUuid, flag) {
  if (flag) {
    return request({
      // url: "/system/login/firstlogin",
      url: "/yybl/login/checkedLogin",
      method: "post",
      data: {
        userCode,
        password,
        verifyCode,
        verifyCodeUuid,
      },
    });
  } else {
    return new Promise((resolve, reject) => {
      resolve({
        msg: "用户名不正确",
      });
    });
  }
}

// 刷新方法
export function refreshToken() {
  return request({
    url: "/system/refresh",
    method: "post",
  });
}

// 获取用户详细信息
export function getInfo() {
  return request({
    url: "/system/user/getInfo",
    method: "get",
  });
}

// getMessageSceneBySceneCode
export function getMessageSceneBySceneCode(data) {
  return request({
    url: "/system/getMessageSceneBySceneCode",
    method: "post",
    data: data,
  });
}

// // 退出方法
// export function logout() {
//   return request({
//     url: "/system/login/logout",
//     method: "post",
//     data: {},
//   });
// }
// 退出方法
export function logout() {
  return request({
    url: "/yybl/login/loginOut",
    method: "post",
    data: {},
  });
}

// 获取验证码
export function getCodeImg() {
  return request({
    url: "/system/code",
    method: "get",
  });
}

/**
 * 找回密码-查询用户是否存在
 * "clientIpList": ["string"],
 * "phonenumber": "string",
 * "userName": "string",
 * "verifyCode": "string",
 * "verifyCodeUuid": "string"
 */
export function queryUser(data) {
  return request({
    url: "/system/findpwd/queryUser",
    method: "post",
    data: data,
  });
}

/**
 * 找回密码-发送验证码
 * email
 * phone
 */
export function sendVerCode(data) {
  return request({
    url: "/system/findpwd/sendVerCodeForFindPwd",
    method: "post",
    data: data,
  });
}

/**
 * 找回密码-验证验证码
 * email
 * phone
 * msgVerCode
 * securityCode
 */
export function checkVerCode(data) {
  return request({
    url: "/system/findpwd/checkVerCodeForFindPwd",
    method: "post",
    data: data,
  });
}

/**
 * 找回密码-重置密码
 * "confirmPwd": "string",
 * "newPwd": "string",
 * "securityCode": "string",
 * "userName": "string"
 */
export function updatePwd(data) {
  return request({
    url: "/system/findpwd/updatePassword",
    method: "post",
    data: data,
  });
}

/**
 * 查询用户的密保问题
 * "userName": "string"
 */
export function querySecurityByUserName(data) {
  return request({
    url: "/system/findpwd/querySecurityByUserName",
    method: "post",
    data: data,
  });
}

/**
 * 验证用户的密保问题
 * "userName": "string"
 */
export function passwordActionRetrievePassword(data) {
  return request({
    url: "/system/findpwd/passwordActionRetrievePassword",
    method: "post",
    data: data,
  });
}

// 二次登录相关
export function getUserLoginRule(data) {
  return request({
    url: "/system/loginrule/getUserLoginRule",
    method: "get",
    params: data,
  });
}

// 获取验证码
export function sendVerCodeForSecondLogin(data) {
  return request({
    url: "/system/login/sendVerCodeForSecondLogin",
    method: "post",
    data: data,
  });
}

// 二次登录
export function secondLogin(data) {
  return request({
    url: "/system/login/secondLogin",
    method: "post",
    data: data,
  });
}

/**
 * 编辑密保状态
 * "userName": "string"
 */
export function updateFirstLoginToN(data) {
  return request({
    url: "/system/user/updateFirstLoginToN",
    method: "post",
    data: data,
  });
}

//亚信4A 第三方登录
export function thirdLogin(params) {
  return request({
    url: "/system/login/externalThirdLogin",
    method: "get",
    params,
  });
}

//泰岳4A 第三方登录
export function thirdTaiyueLogin(params) {
  return request({
    url: "/system/login/externalTyThirdLogin",
    method: "get",
    params,
  });
}

//甘肃 第三方登录
export function thirdGansuLogin(params) {
  return request({
    url: "/system/login/thirdLoginForGS",
    method: "get",
    params,
  });
}

//验证当前密码是否符合密码规则
// export function firstCheckPwd(params) {
//   return request({
//     url: "/system/user/firstCheckPwd",
//     method: "post",
//     data: params,
//   });
// }

// 登录方法
export function firstCheckPwd(userName, password, verifyCode, verifyCodeUuid) {
  return request({
    url: "/system/user/firstCheckPwd",
    method: "post",
    data: {
      userName,
      password,
      verifyCode,
      verifyCodeUuid,
    },
  });
}
